/*
  Tên:Nguyễn Văn Huy
  MSSV:11374891
  Lớp:DHTH7DLT
  Ngày hoàn thành:28/04/2012
  */
#include "frdanhsachsach.h"
#include "ui_frdanhsachsach.h"
#include "mysqlconnection.h"
frdanhsachsach::frdanhsachsach(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::frdanhsachsach)

{
    ui->setupUi(this);
    loadsach();
}

frdanhsachsach::~frdanhsachsach()
{
    delete ui;
}

void frdanhsachsach::loadsach()
{
    MySqlConnection *DB=new MySqlConnection();
    DB->Open();
    QSqlQueryModel *model = new QSqlQueryModel();
    model->setQuery("SELECT s1.TenSach,s2.TenTheLoai,t.TenTacGia,s1.SoLuongTon FROM QLBSach.Sach s1 join QLBSach.Sach s2 join QLBSach.TacGia t where s2.MaSach = s1.MaTheLoai and s1.MaTacGia=t.MaTacGia order by s1.MaSach desc", DB->DB);
    ui->tbsach->setModel(model);
    ui->tbsach->show();
    ui->tbsach->setColumnWidth(0,300);
    ui->tbsach->setColumnWidth(1,200);
    ui->tbsach->setColumnWidth(2,200);
    ui->tbsach->setColumnWidth(3,70);
    DB->Close();
}

void frdanhsachsach::hienthi()
{
}

void frdanhsachsach::thoat()
{
}
